Skip to content

Conversation

@OlivierBlanvillain
Copy link
Contributor

This PR cleans up config.Printers imports to make them more grep-able. These changes go in pair with the following updates on https://github.com/lampepfl/dotty/wiki/Workflow:


Compiling files with dotc

From sbt:

run <OPTIONS> <FILE>

From terminal:

$ ./bin/dotc <OPTIONS> <FILE>

Here are some useful debugging :

  • -Xprint:PHASE1,PHASE2,... or -Xprint:all: prints the AST after each specified phase. Phase names can be found by searching src/dotty/tools/dotc/transform/ for phaseName.
  • -Ylog:PHASE1,PHASE2,... or -Ylog:all: enables ctx.log("") logging for the specified phase.
  • -Ycheck:all verifies the consistency of AST nodes between phases, in particular checks that types do not change (option enabled in tests)

Additional logging information can be obtained by changes some noPrinter to new Printer in src/dotty/tools/dotc/config/Printers.scala. This enables the subtyping.println("") and ctx.traceIndented("", subtyping) style logging.

Running tests

From sbt:

partest --show-diff --verbose

Type Stealer

There is no power mode for the repl yet, but you can inspect types with the type stealer:

$ ./bin/dotc -repl
scala> import test.DottyTypeStealer._; import dotty.tools.dotc.core._; import Contexts._,Types._;

Now, you can define types and access their representation. For example:

scala> val s = stealType("class O { type X }", "O#X")
scala> implicit val ctx: Context = s._1
scala> val t = s._2(0)
t: dotty.tools.dotc.core.Types.Type = TypeRef(TypeRef(ThisType(TypeRef(NoPrefix,<empty>)),O),X)
scala> val u = t.asInstanceOf[TypeRef].underlying
u: dotty.tools.dotc.core.Types.Type = TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,scala)),Nothing), TypeRef(ThisType(TypeRef(NoPrefix,scala)),Any))

Pretty-printing

Many objects in the dotc compiler implement a Showable trait (e.g. Tree, Symbol, Type). These objects may be prettyprinted using the .show method

And remove the not used Printer#echo
@OlivierBlanvillain
Copy link
Contributor Author

@felixmulder Could you review both the commit and the wiki changes?

Copy link
Contributor

@felixmulder felixmulder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot, great job! We need to unclutter a few things and this is definitely a step in the right direction!

As discussed, we need to standardize on printing between ctx.log and the different printers in Printers.scala. But that can be separate from this.

Cheers

@felixmulder felixmulder merged commit 28940d3 into scala:master Sep 23, 2016
@OlivierBlanvillain OlivierBlanvillain deleted the clean-up-printers branch September 23, 2016 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants